package repository

import (
	"context"
	"database/sql"

	dbmodel "gitee.com/hp-huiw/family-expense-api/internal/db/model"
)

type AppErrorReportRepository interface {
	Insert(ctx context.Context, model *dbmodel.AppErrorReport) error
}

func NewAppErrorReportRepository(db *sql.DB) AppErrorReportRepository {
	return &appErrorReportRepository{db: db}
}

// Insert deletes all appErrorReports by account group id with transaction.
func (r *appErrorReportRepository) Insert(ctx context.Context, model *dbmodel.AppErrorReport) error {
	stmt := tbErrorReport.
		INSERT().
		MODEL(model)

	_, err := stmt.ExecContext(ctx, r.db)

	return err
}

type appErrorReportRepository struct {
	db *sql.DB
}
